<template>
<div id="main-navigation" :class="{'show':display,'hide':!display}">
  <div class="hidden show-bottom" @click="switchShow(false)"  v-if="display">
    <a-icon type="caret-right" />
  </div>
  <div class="show-left show-bottom" @click="switchShow(true)" v-if="!display">
    <a-icon type="caret-left" />
  </div>
  <div class="title">
    Application
  </div>
  <div class="navigation-item">
    <div class="item-container" v-for="i in apps">
      <a-tooltip>
        <template slot="title">
          {{i.description}}
        </template>
      <div class="item" @click="goto(i.path)" :class="{'active':active(i.path)}">
        <a-icon class="t-icon"  :type="i.icon"/>
        <div class="name">
          {{i.name}}
        </div>
      </div>
      </a-tooltip>
    </div>
  </div>
</div>
</template>

<script>
export default {
  name: "Navigation",
  data(){
    return {
      display:true,
      apps:[
        {
          name:'节点控制台',
          description:'当前在线节点总览,节点当前的负载情况',
          icon:'cloud',
          path:"/console"
        },
        {
          name:'webhook',
          description:'基于此平台二次开发的单个任务,用于构建CI/CD,使用webhook触发,程序会初始化一个干净的docker container 环境,您可以使用shell编写自己的构建过程',
          icon:'global',
          path:"/console/webhook"
        },
        {
          name:'任务编写节点',
          description:'任务以及项目开发的地方',
          icon:'appstore',
          path:"/console/programe"
        },
      ]
    }
  },
  created(){
  },
  methods:{
    goto(path){
      this.$router.push(path)
    },
    switchShow(show){
      this.display = show;
    },
    active(path){
      return this.$route.path==path
    }
  }
}
</script>

<style scoped>
.navigation-item{
  display: flex;
  flex-wrap: wrap;
  cursor: pointer;
}
.item-container{
  position: relative;
  padding: 5px 5px;
}
.item{
  width: 90px;
  height: 90px;
  border-radius: 5px;
  background-color: rgba(119, 136, 153, 0.55);
  margin-top: 20px;
}
.t-icon{
  width: 100%;
  display: block;
  text-align: center;
  color: white;
  font-size: 30px;
  height: 50px;
  line-height: 55px;
}
.t-icon:hover{
  transform: scale(1.5);
  font-weight: bolder;
}
.item:hover{
  background-color: rgba(30, 144, 255, 0.75);
}

#main-navigation{
  z-index: 999;
  position: fixed;
  top: 100px;
  width: 200px;
  height: 400px;
  border-radius: 10px;
  background-color: rgba(255, 255, 255, 0.36);
}
.title{
  color: white;
  text-align: center;
  font-size: 20px;
}
.name{
  width: 100%;
  text-align: center;
  color: white;
}
.show{
  right: 50px;
  transition: 0.5s ease-in-out;
}
.hide{
  right: -200px !important;
  transition: 0.5s ease-in-out;
}
.hidden{
  position: absolute;
  right: -50px;
  top:40%;
  color: white;
  font-size: 40px;
}
.show-bottom:hover{
  transform: scale(1.5);
  transition: 0.2s ease-in-out;
  color: dodgerblue;
}
.show-left{
  position: absolute;
  left: -50px;
  top:40%;
  color: white;
  font-size: 40px;
}
.active{
  background-color: rgba(30, 144, 255, 0.75);
}
</style>
